package com.jiang.demo.springbootmultidatasources.web;

import com.jiang.demo.springbootmultidatasources.entity.db1.User;
import com.jiang.demo.springbootmultidatasources.entity.db2.Student;
import com.jiang.demo.springbootmultidatasources.repository.db1.UserRepository;
import com.jiang.demo.springbootmultidatasources.repository.db2.StudentRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/test-multi-ds")
public class TestController {

    @Autowired
    UserRepository userRepository;

    @Autowired
    StudentRepository studentRepository;

    @GetMapping("/getAllUser")
    public List<User> getAllUser(){
        return userRepository.findAll();
    }

    @GetMapping("/getAllStudent")
    public List<Student> getAllStudents(){
        return studentRepository.findAll();
    }
}
